package tt.dz.egobus.servicemanager.vo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
import tt.dz.egobus.servicemanager.bean.EntityViewVo;
import tt.dz.egobus.servicemanager.entities.Bus;
import tt.dz.egobus.servicemanager.entities.DriverRegisterBusRelative;

import java.util.Date;

/**
 * @author Anson
 * @date 17-8-25
 * @name 司机绑定车辆关系Vo
 * @since 1.0.6
 */
public class DriverRegisterBusRelativeViewVo implements EntityViewVo<DriverRegisterBusRelative,
        DriverRegisterBusRelativeViewVo> {

    private static final Logger LOGGER = LoggerFactory.getLogger(DriverRegisterBusRelativeViewVo.class);
    private static final long serialVersionUID = 8575593952182327014L;

    @Override
    public DriverRegisterBusRelative convert() {
        DriverRegisterBusRelative pojo = new DriverRegisterBusRelative();
        try {
            BeanUtils.copyProperties(this, pojo);
        } catch (BeansException e) {
            LOGGER.error("DriverRegisterBusRelativeViewVo -> DriverRegisterBusRelative bean拷贝异常, viewVo={}", this, e);
        }
        return pojo;
    }

    @Override
    public DriverRegisterBusRelativeViewVo view(DriverRegisterBusRelative pojo) {
        if (pojo == null) {
            return this;
        }
        this.setId(pojo.getId());
        this.setBusId(pojo.getBusId());
        this.setDriverId(pojo.getDriverId());
        this.setDriverName(pojo.getDriverName());
        this.setPhoneNumber(pojo.getPhoneNumber());
        this.setIdCard(pojo.getIdCard());
        this.setStatus(pojo.getStatus());
        this.setIsValidate(pojo.getIsValidate());
        this.setCreateTime(pojo.getCreateTime());
        this.setEndTime(pojo.getEndTime());
        Bus bus = pojo.getBus();
        if (bus != null) {
            this.setCarNo(bus.getCarNo());
        }
        return this;
    }

    private String id;


    /**
     * 车辆id
     */
    private String busId;

    /**
     * 司机id
     */
    private String driverId;

    /**
     * 司机真实姓名
     */
    private String driverName;

    /**
     * 司机手机号码
     **/
    private String phoneNumber;
    /**
     * 身份证号码
     **/
    private String idCard;

    /**
     * 状态 0:未激活;10:激活;15,抢单;20:开始;30:进行;40:完毕;50：取消行程;60,下线;-10:异常
     */
    private int status;

    /**
     * 是否失效
     */
    private boolean isValidate = false;


    /**
     * 创建时间
     */
    private Date createTime;


    /**
     * 结束时间
     */
    private Date endTime;


    /**
     * 车牌
     */
    private String carNo;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getBusId() {
        return busId;
    }

    public void setBusId(String busId) {
        this.busId = busId;
    }

    public String getDriverId() {
        return driverId;
    }

    public void setDriverId(String driverId) {
        this.driverId = driverId;
    }

    public String getDriverName() {
        return driverName;
    }

    public void setDriverName(String driverName) {
        this.driverName = driverName;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public String getIdCard() {
        return idCard;
    }

    public void setIdCard(String idCard) {
        this.idCard = idCard;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public boolean getIsValidate() {
        return isValidate;
    }

    public void setIsValidate(boolean isValidate) {
        isValidate = isValidate;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public String getCarNo() {
        return carNo;
    }

    public void setCarNo(String carNo) {
        this.carNo = carNo;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        DriverRegisterBusRelativeViewVo that = (DriverRegisterBusRelativeViewVo) o;

        if (status != that.status) return false;
        if (isValidate != that.isValidate) return false;
        if (id != null ? !id.equals(that.id) : that.id != null) return false;
        if (busId != null ? !busId.equals(that.busId) : that.busId != null) return false;
        if (driverId != null ? !driverId.equals(that.driverId) : that.driverId != null) return false;
        if (driverName != null ? !driverName.equals(that.driverName) : that.driverName != null) return false;
        if (phoneNumber != null ? !phoneNumber.equals(that.phoneNumber) : that.phoneNumber != null) return false;
        if (idCard != null ? !idCard.equals(that.idCard) : that.idCard != null) return false;
        if (createTime != null ? !createTime.equals(that.createTime) : that.createTime != null) return false;
        if (endTime != null ? !endTime.equals(that.endTime) : that.endTime != null) return false;
        return carNo != null ? carNo.equals(that.carNo) : that.carNo == null;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (busId != null ? busId.hashCode() : 0);
        result = 31 * result + (driverId != null ? driverId.hashCode() : 0);
        result = 31 * result + (driverName != null ? driverName.hashCode() : 0);
        result = 31 * result + (phoneNumber != null ? phoneNumber.hashCode() : 0);
        result = 31 * result + (idCard != null ? idCard.hashCode() : 0);
        result = 31 * result + status;
        result = 31 * result + (isValidate ? 1 : 0);
        result = 31 * result + (createTime != null ? createTime.hashCode() : 0);
        result = 31 * result + (endTime != null ? endTime.hashCode() : 0);
        result = 31 * result + (carNo != null ? carNo.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "DriverRegisterBusRelativeViewVo{" + "id='" + id + '\'' + ", busId='" + busId + '\'' + ", driverId='"
                + driverId + '\'' + ", driverName='" + driverName + '\'' + ", phoneNumber='" + phoneNumber + '\'' +
                ", idCard='" + idCard + '\'' + ", status=" + status + ", isValidate=" + isValidate + ", createTime="
                + createTime + ", endTime=" + endTime + ", carNo='" + carNo + '\'' + '}';
    }
}
